﻿using IceCS.GoodsSale.DAL;
using IceCS.GoodsSale.Models.GoodsModels;
using IceCS.GoodsSale.Models.UserModels;

namespace IceCS.GoodsSale.BLL
{
    public class PublicMethodsManager
    {
        PublicMethodsAccesser publicMethods = new PublicMethodsAccesser();

        //在UI层修改密码时，调用DAL层的GetMd5Str()，判断旧密码是否正确调用
        public string GetMd5OfPassword(string myString)
        {
            return publicMethods.GetMd5Str(myString);
        }

        //调用DAL层的InsertUserToTwoTable()，添加用户的方法
        public bool AddUserToTwoTable(User user, UserPurview userPurview)
        {
            return publicMethods.InsertUserToTwoTable(user, userPurview);
        }

        //调用DAL层的DeleteUserFromThreeTable()，删除用户的方法
        public bool RemoveUserFromThreeTable(string userName)
        {
            return publicMethods.DeleteUserFromThreeTable(userName);
        }

        //调用DAL层的InsertSaleDataUpdateInventory()，添加销售数据和修改库存的方法
        public bool AddSaleDataChangeInventory(Sale sale, int inventory)
        {
            return publicMethods.InsertSaleDataUpdateInventory(sale, inventory);
        }

        //调用DAL层的BackupDB()，备份数据库的方法
        public bool BackupDB(string backupPath)
        {
            return publicMethods.BackupDB(backupPath);
        }

        //调用DAL层的RestoreDB()，恢复数据库的方法
        public bool RestoreDB(string restorePath)
        {
            var serverName = "";
            return publicMethods.RestoreDB(serverName, restorePath);
        }
    }
}
